home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 19 / madtrb40.zip / EPSONLDR.PAS < prev    next >
Pascal/Delphi Source File  |  1986-05-18  |  11KB  |  250 lines

  1. Program EpsonLdr;
  2. Const
  3.   MaxChar = 255;
  4. Type
  5.   Fontype = array[0..11] of integer;
  6.   Filetype = file of fontype;
  7.   Str255   = String[255];
  8.   Str80    = String[80];
  9.   Str4     = array[1..4] of char;
  10.  
  11. Var
  12.   Font     :  array[0..MaxChar] of Fontype;
  13.   Fontfile :  Filetype;
  14.   ColNum   :  Integer;
  15.   Error    :  Str80;
  16.   Ans      :  Integer;
  17.   Extension:  Str4;
  18.   CharNum  :  Integer;
  19.  
  20. {$I Beep.inc }
  21. {$I Answer.inc }
  22. {$I Files.inc }
  23. {$I DirExt.inc }
  24.  
  25. Begin
  26.   Error := 'O';
  27.   Extension[1] := '.';
  28.   Extension[2] := 'F';
  29.   Extension[3] := 'N';
  30.   Extension[4] := 'T';
  31.   writeln('EPSON font file loader.         by C.A. Rinehart (c) 1986');
  32.   writeln('   Present font file names are: ');
  33.   ListDirectory;
  34.   writeln;
  35.   repeat
  36.     OpenFile(FontFile,Error,Extension);
  37.     If Error <> '' then
  38.       begin
  39.        writeln(Error);
  40.        write('Try another file? (Y/N)  ');
  41.        Answer('yes,no',Ans,false);
  42.       end;
  43.   until (Ans = 2) or (Error = '');
  44.   if Error = '' then
  45.     begin
  46.       write(Lst,chr(27),chr(38),chr(0),chr(1),chr(maxchar));
  47.       CharNum := 0;
  48.       while  NOT EOF(FontFile) do
  49.         begin
  50.           read(fontfile, font[CharNum]);
  51.           CharNum := CharNum  + 1;
  52.         end;
  53.       for CharNum := 0 to MaxChar do
  54.           for ColNum := 0 to 11 do write(Lst,chr(font[CharNum,ColNum]));
  55.     end
  56.   else
  57.     begin
  58.       writeln;
  59.       writeln('No characters read from file!');
  60.       beep(1);
  61.       delay(2000);
  62.     end;
  63.   CloseFile(FontFile, Error);
  64.   if Error <> '' then
  65.     begin
  66.       writeln('Close file error:');
  67.       writeln(Error);
  68.       beep(1);
  69.       delay(2000);
  70.     end;
  71. end.
  72.  
  73.  
  74. (*
  75. Procedure DirectoryModule;
  76.  
  77. { *************************************************************************** }
  78. { *                                                                         * }
  79. { *                            DIRECTORY MODULE                             * }
  80. { *                                                                         * }
  81. { *      This module controls the display of the disk directory window.     * }
  82. { *      This module will only list those files with the three character    * }
  83. { *      extension defined for the input data files allowed for this        * }
  84. { *      particular application of the pre-processor.  Note that the        * }
  85. { *      three character input data file extension is declared in the       * }
  86. { *      constant header in the file 'Main.Mod'.                            * }
  87. { *                                                                         * }
  88. { *      This method was selected since the user only needs to see those    * }
  89. { *      files that are input data files specific to the particular         * }
  90. { *      application of the pre-processor.                                  * }
  91. { *                                                                         * }
  92. { *      Note that an interesting project might be re-writing this module   * }
  93. { *      to show the subdirectories in one color and the input data files   * }
  94. { *      in a different color, just like the Turbo editor does.             * }
  95. { *                                                                         * }
  96. { *************************************************************************** }
  97.  
  98. Var
  99.   LoggedDirectory:WorkString;          { a string used to temporarily store the currently logged directory }
  100.   ExistantDirectory:Boolean;           { a boolean used in checking if specified directory is existant }
  101.  
  102.  
  103.  
  104.   Procedure ListDirectory;
  105.  
  106.   { This procedure lists out all the valid input data files with the declared
  107.     input data file extension constant in the directory window. }
  108.  
  109.   Type    { ListDirectory }
  110.     CharArray=Array [1..12] Of Char;   { array type of character used in looking for input data files }
  111.     WorkString=String[20];             { string type used for file names }
  112.     RecordOfRegisters=                 { a record type to store the integer values of the 8088 internal registers }
  113.       Record
  114.         AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags : Integer;   { Registers }
  115.       End; { RecordOfRegisters }
  116.  
  117.   Var
  118.     Registers:RecordOfRegisters;       { record variable used to store the integer values of the 8088 internal registers }
  119.     DTA:Array [ 1..43 ] Of Byte;       { Data Transfer Area }
  120.     Mask:CharArray;                    { an array used to store the input file name mask }
  121.     FileName:WorkString;               { a variable used to store a filename found in the directory }
  122.     Error:Integer;                     { a variable used to store the returned error code }
  123.     I:Integer;                         { an index counter used in returning file names }
  124.     J:Integer;                         { an index counter used in placing spaces between the acquired file names }
  125.  
  126.   Begin
  127.     FillChar(DTA,SizeOf(DTA),0);       { initialize the DTA buffer }
  128.     FillChar(Mask,SizeOf(Mask),0);     { initialize the mask }
  129.     FillChar(FileName,SizeOf(FileName),0); { initialize the file name }
  130.     Registers.AX:=$1A00;               { function used to set the DTA }
  131.     Registers.DS:=Seg(DTA);            { store the parameter segment in the data egment register DS }
  132.     Registers.DX:=Ofs(DTA);            { stare the parameter offset in the data register DX }
  133.     MSDos(Registers);                  { set DTA location }
  134.     Error:=0;                          { initialize error flag }
  135.     Mask:='????????.???';              { use for search of input data files }
  136.     Mask[9]:=INPUT_FILE_NAME_EXTENSION[1]; { used for looking for input files with a particular file name extension }
  137.     Mask[10]:=INPUT_FILE_NAME_EXTENSION[2];
  138.     Mask[11]:=INPUT_FILE_NAME_EXTENSION[3];
  139.     Mask[12]:=INPUT_FILE_NAME_EXTENSION[4];
  140.     Registers.AX:=$4E00;               { get first directory entry }
  141.     Registers.DS:=Seg(Mask);           { point to the file Mask }
  142.     Registers.DX:=Ofs(Mask);
  143.     Registers.CX:=22;                  { store the option }
  144.     MSDos(Registers);                  { execute MSDos call }
  145.     Error:=Registers.AX and $FF;       { get Error return }
  146.     I:=1;                              { initialize 'I' to the first element }
  147.     If (Error=0) Then
  148.       Repeat
  149.         FileName[I]:=Chr(Mem[Seg(DTA):Ofs(DTA)+29+I]);
  150.         I:=I+1;
  151.       Until Not (FileName[I-1] in [' '..'~']) or (I>20);
  152.     FileName[0] := Chr(I-1);           { set string length because assigning by element does not set length }
  153.     If (Error=0) Then
  154.       Begin                            { remove data file name extension }
  155.         Delete(FileName,Length(FileName)-4,4);
  156.         Write(FileName);
  157.         For J:=Length(FileName)+1 To 10 Do { place spaces between file names so that they line up vertically }
  158.           Write(' ');
  159.       End; { If Error }
  160.     While (Error=0) Do
  161.       Begin
  162.         Error:=0;                      { initialize error flag }
  163.         Registers.AX:=$4F00;           { function used to get the next directory entry }
  164.         Registers.CX:=22;              { set the file option }
  165.         MSDos(Registers);              { call MSDos }
  166.         Error:=Registers.AX and $FF;   { get the Error return }
  167.         I:=1;
  168.         Repeat
  169.           FileName[I]:=Chr(Mem[Seg(DTA):Ofs(DTA)+29+I]);
  170.           I:=I+1;
  171.         Until Not (FileName[I-1] in [' '..'~'] ) or (I > 20);
  172.         FileName[0]:=Chr(I-1);
  173.         If (Error=0) Then
  174.           Begin                        { remove data file name extension }
  175.             Delete(FileName,Length(FileName)-4,4);
  176.             Write(FileName);
  177.             For J:=Length(FileName)+1 To 10 Do { place spaces between file names so that they line up vertically }
  178.               Write(' ');
  179.           End; { If Error }
  180.       End; { While Error }
  181.   End;    { ListDirectory }
  182.  
  183.  
  184.  
  185.   Procedure ShowDirectoryWindow(    ExistantDirectory:Boolean);
  186.  
  187.   { This procedure overlays a directory window to list out input data files on
  188.     top of the current page if the passed ExistantDirectory is true, else it
  189.     displays an error message and removes the incorrectly entered directory
  190.     path. }
  191.  
  192.   Var
  193.     TextString:WorkString;             { string variable used in getting the currently logged directory }
  194.  
  195.   Begin   { ShowDirectoryWindow }
  196.     StoreTextScreen(1);                { take snapshot of the screen }
  197.     If ExistantDirectory Then
  198.       Begin                            { place directory window on top of current page }
  199.         TextColor(InputWindowBorderColor);
  200.         TextBackground(InputWindowColor);
  201.         SoundAttention;
  202.         ZoomWindow2(4,17,77,24);
  203.         TextColor(HighlightColor);
  204.         GetDir(0,TextString);          { get directory label containing input data files }
  205.         WriteCenterText(17,'Directory Listing of '+TextString);
  206.         TextColor(ForegroundColor);
  207.         WriteCenterText(24,'Strike any key to continue');
  208.         Window(12,18,71,23);
  209.         GotoXY(1,1);
  210.         TextColor(HighlightColor);
  211.         ListDirectory;
  212.         Window(1,1,80,25);
  213.       End { If ExistantDirectory }
  214.     Else                               { tell user that directory path specified is non-existent }
  215.       Begin
  216.         TextColor(ForegroundColor);
  217.         TextBackground(BackgroundColor);
  218.         SoundAttention;
  219.         ZoomWindow1(4,5,77,7);
  220.         TextColor(HighlightColor);
  221.         WriteCenterText(6,'The above specified directory path is non-existant');
  222.         TextColor(ForegroundColor);
  223.         WriteCenterText(7,'Strike any key to continue');
  224.  
  225.         { following routine is specific to example application of the input pre-processor }
  226.         G_I_Data[2,1]^:='';            { delete wrongly entered directory path }
  227.  
  228.       End; { Not a existent directory }
  229.   End;    { ShowDirectoryWindow }
  230.  
  231.  
  232.  
  233. Begin   { DirectoryModule }
  234.   ExistantDirectory:=True;             { initialize boolean flag }
  235.   GetDir(0,LoggedDirectory);           { temporarily store the currently logged directory }
  236.   { following routine is specific to the example application of the input pre-processor }
  237.   If G_I_Data[2,1]^<>'' Then           { check if user has specified a directory path }
  238.     Begin
  239.       {$I-}                            { I/O error checking is set to passive state }
  240.       ChDir(G_I_Data[2,1]^);           { attempt to change directories }
  241.       {$I+}                            { I/O error checking is set to active state }
  242.       ExistantDirectory:=(IOresult=0); { If ExistantDirectory=True, then directory exists }
  243.     End; { If G_I_Data }
  244.   ShowDirectoryWindow(ExistantDirectory);
  245.   If Not ExistantDirectory Then
  246.     Write_G_I_Entries;                 { this removes the wrongly entered directory path }
  247.   ChDir(LoggedDirectory);              { change back to the previously logged directory }
  248.   WaitUntilKeypressed;
  249.   RemoveWindow;
  250. End;    { DirectoryModule }*)